var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/lagou-admin', {
  useUnifiedTopology: true, 
  useNewUrlParser: true
  // useFindAndModify: true
});

var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
// 构建users的model
var userSchema = mongoose.Schema({
  username: {
    type: String,
    required: true
  },
  password: {
    type: String,
    required: true
  }
});

var Users = mongoose.model('users', userSchema)
// > db.getCollectionNames()
// [ "users" ] 如果不是复数自动加s 
// db.users.find()

// var user = new Users({ name: 'Felyne' });
// console.log(user.name); // 'Felyne'
// user.save()

var positionsSchema = mongoose.Schema({
  companyLogo: String,
  companyName: String,
  positionName: String,
  city: String,
  createTime: String,
  salary: String
})
var Positions = mongoose.model('positions', positionsSchema)

exports.Users = Users
exports.Positions = Positions
